package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.db.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface LogMapper extends BaseMapper<Log> {

    // 根据类型和时间统计用户数
    @Select("select count(DISTINCT user_id) from tb_log where type=#{type} and log_time=#{time}")
    public Integer findTypeAndTime(@Param("type")String type,@Param("time") String time);
    // 根据时间统计用户数
    @Select("select count(DISTINCT user_id) from tb_log where log_time=#{time}")
    public Integer findByTime(String time);
    // 根据昨天和今日统计用户数
    @Select("select count(DISTINCT user_id) from tb_log where log_time=#{today} and user_id in(" +
            "select DISTINCT user_id from tb_log where log_time=#{yesterday} and type = '0102' )")
    public Integer findByTodayAndYesterday(@Param("today")String today,@Param("yesterday")String yesterday);
}